import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import User from "../views/User"
import Student from "../views/Student";
import UserAdd from "../views/UserAdd";
import UserEdit from "../views/UserEdit";

Vue.use(VueRouter)

const routes = [
    {
        path: '/',
        name: 'Home',
        component: Home
    },
    {
        path: '/home',
        component: Home
    },
    {
        path: '/user',
        component: User,
        children: [
            {path: 'add', component: UserAdd},//子路由的path不要加斜杠，因为如果加了就是绝对路径
            {path: 'edit/:id',component: UserEdit}  //restful风格使用冒号声明参数，传统方式无需声明，直接用问号后接参数
        ]
    },
    {
        path: '/student',
        component: Student
    }
]

const router = new VueRouter({
    routes
})

export default router
